<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>title</title>
  <!--按顺序引入-->
  <script src="https://cdn.staticfile.org/react/16.8.4/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.8.4/umd/react-dom.development.js"></script>
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
  <script src="../js/babel.min.js"></script>
  <style>
    body {
      width: 95vw;
      height: 80vh;
      background-color: #2b2b2b;
      color: wheat;
    }
  </style>
</head>
<body>
<div id="app"></div>

<script type="text/babel">
  // 类式组件
  class Weather extends React.Component {
    // 初始化state
    state = {isHot: false}

    render() {
      return <h1 onClick={this.changeWeather}>今天天气很{this.state.isHot ? '炎热' : '不炎热'}</h1>
    }

    // 自定义方法 箭头函数 this指向组件实例
    changeWeather = () => {
      this.setState({isHot: !this.state.isHot})
    }
  }

  // 渲染
  ReactDOM.render(<Weather/>, document.getElementById('app'))
</script>
</body>
</html>
